\name{fill.gap}

\alias{fill.gap}

\title{Fill a gap in an oce object}

\description{Fill a gap in an oce object}

\usage{fill.gap(x, start, end, column)}

\arguments{
  \item{x}{an \code{oce} object.}
  \item{start}{the start of the bad section of data (see details).}
  \item{end}{the start of the bad section of data (see details).}
  \item{column}{if provided, the name of the column referred to by
    \code{start} and \code{end}.}
}

\details{Gaps in the data (i.e. columns in \code{x$data}) are filled by
  linear interpolation between the \code{start} and \code{end} points.
  If \code{column} is not provided, then \code{start} and \code{end} are
  indices.  If \code{column} is provided, then \code{start} and
  \code{end} refer to values in the named column.}

\value{A new \code{oce} object.}

\examples{
library(oce)
data(pt)
# mess up a day
d <- pt
d$data$temperature[as.POSIXct("2008-06-27", tz="UTC")<=d$data$time & d$data$time <= as.POSIXct("2008-06-28", tz="UTC")] <- 20
plot(d, which=1)
# fix that day by linear interpolation
dd <- fill.gap(d, as.POSIXct("2008-06-27", tz="UTC"), as.POSIXct("2008-06-28", tz="UTC"), "time")
lines(dd$data$time, dd$data$temperature, col="red")
}

\author{Dan Kelley}

\keyword{misc}
